EC2(Amazon Linux 2023)でGatlingを使えるようにしてみた

EC2(Amazon Linux 2023)でGatlingを使えるようにしてみた

Clock Icon2024.07.23

こんにちは、ゲームソリューション部のsoraです。
今回は、EC2(Amazon Linux 2023)でGatlingを使えるようにしてみたことについて書いていきます。

OpenJDKのインストール

負荷試験ツールのGatlingを利用するにはOpenJDKが必要なため、OpenJDKをインストールします。
公式ドキュメントにGatlingがサポートするOpenJDKのバージョンの記載があったため、それに従ってOpenJDK 21をインストールします。

Gatling supports 64-bit OpenJDK LTS (Long Term Support) versions: 11, 17, and 21. Other JVMs such as, 32-bit systems or OpenJ9, are not supported. We recommend the Azul JDK.
https://docs.gatling.io/reference/install/oss/

# OpenJDKのディストリビューションであるAmazon Correttoを検索
$ sudo dnf search amazon corretto

# OpenJDK v21のインストール
$ sudo dnf install java-21-amazon-corretto-devel

# インストール後の確認
$ java -version
openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment Corretto-21.0.4.7.1 (build 21.0.4+7-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.4.7.1 (build 21.0.4+7-LTS, mixed mode, sharing)

Gatlingのダウンロード

次にGatlingをダウンロードします。
以下にzipファイルが配置されているため、取得したバージョンを確認します。
https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/

# zipファイルの取得
$ wget https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/3.9.5/gatling-charts-highcharts-bundle-3.9.5-bundle.zip
# ※現状の最新バージョンのつもりで3.9.5をインストールしましたが、3.11.5が最新だったため、最新版でないものをダウンロードしています。

# zipファイルの展開
$ unzip gatling-charts-highcharts-bundle-3.9.5-bundle.zip

動作確認

これでGatlingが使えるようになったため、動作確認をしてみます。

$ ls
gatling-charts-highcharts-bundle-3.9.5  gatling-charts-highcharts-bundle-3.9.5-bundle.zip

$ cd gatling-charts-highcharts-bundle-3.9.5

$ bin/gatling.sh
GATLING_HOME is set to /home/ec2-user/gatling-charts-highcharts-bundle-3.9.5
Do you want to run the simulation locally, on Gatling Enterprise, or just package it?
Type the number corresponding to your choice and press enter
[0] <Quit>
[1] Run the Simulation locally
[2] Package and upload the Simulation to Gatling Enterprise Cloud, and run it there
[3] Package the Simulation for Gatling Enterprise
[4] Show help and exit
1
Gatling 3.11.5 is available! (you're using 3.9.5)
computerdatabase.ComputerDatabaseSimulation is the only simulation, executing it.
Select run description (optional)

Simulation computerdatabase.ComputerDatabaseSimulation started...
…
================================================================================
---- Global Information --------------------------------------------------------
> request count                                        108 (OK=104    KO=4     )
> min response time                                    146 (OK=146    KO=150   )
> max response time                                    504 (OK=504    KO=159   )
> mean response time                                   194 (OK=196    KO=154   )
> std deviation                                        100 (OK=101    KO=4     )
> response time 50th percentile                        160 (OK=160    KO=154   )
> response time 75th percentile                        168 (OK=168    KO=158   )
> response time 95th percentile                        477 (OK=478    KO=159   )
> response time 99th percentile                        502 (OK=503    KO=159   )
> mean requests/sec                                      6 (OK=5.778  KO=0.222 )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                           104 ( 96%)
> 800 ms <= t < 1200 ms                                  0 (  0%)
> t >= 1200 ms                                           0 (  0%)
> failed                                                 4 (  4%)
---- Errors --------------------------------------------------------------------
> status.find.is(201), but actually found 200                         4 (100.0%)
================================================================================

Reports generated in 0s.
Please open the following file: file:///home/ec2-user/gatling-charts-highcharts-bundle-3.9.5/results/computerdatabasesimulation-20240723023248044/index.html

実行できたため、生成された実行結果について、resultsフォルダ配下のindex.htmlファイルを開いて確認してみます。
sr-ec2-2023-gatling

参考

https://qiita.com/hogucc/items/e213a93f5b3a3cd3c96f
https://docs.gatling.io/reference/install/oss/

最後に

今回は、EC2(Amazon Linux 2023)でGatlingを使えるようにしてみたことを記事にしました。
どなたかの参考になると幸いです。

この記事をシェアする

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.